Skip to content

Refactor (packages/ui/src/v2/components/tooltip-v2.tsx): Function with many returns - #53

Open
amrashee wants to merge 1 commit into
CMU-17313Q:mainfrom
amrashee:refactor-tooltip-returns
Open

Refactor (packages/ui/src/v2/components/tooltip-v2.tsx): Function with many returns#53
amrashee wants to merge 1 commit into
CMU-17313Q:mainfrom
amrashee:refactor-tooltip-returns

Conversation

@amrashee

@amrashee amrashee commented Sep 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #20

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

Qlty reported that TooltipV2 had too many returns. I changed the drop logic so it uses a helper called shouldDropBlock instead of having multiple early returns. The helper checks if the tooltip is expanded, hovered, or has focus inside. If any of these are true, the block stays. This keeps the same behavior but removes the Qlty smell I claimed.
-Before: 'Function with many returns (count = 8): TooltipV2'
-After: the "Function with many returns" smell is no longer reported.

How did you verify your code works?

I added tests for the different cases in shouldDropBlock. The new tests passed (4/4), and I also ran the full UI tests which passed (31/31). I ran coverage as well and the new helper has 100% line and function coverage. I also ran Qlty again to make sure the smell was gone.

Screenshots / recordings

Before Qlty:

before

After Qlty:

after

Tests:

test passing

Coverage:

coverage

Bun lint: bun lint reports 698 warnings and 2 errors. I checked the untouched upstream main branch and got the same result. Professor Eduardo confirmed that the 2 errors were already part of the codebase and do not need to be fixed.

image image

If this is a UI change, please include a screenshot or recording.

There is no visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@amrashee
amrashee force-pushed the refactor-tooltip-returns branch from 03c530d to 8286ff5 Compare September 3, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P1B: Refactor (packages/ui/src/v2/components/tooltip-v2.tsx:16): Function with many returns (count = 8)

1 participant